package com.topvision.myviewtest.recycler.itemdecoration;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Paint;
import android.support.v7.widget.RecyclerView;
import android.text.TextPaint;

import com.topvision.myviewtest.R;

/**
 * @author lucy
 * @date 2018-03-28 15:52
 * @description //吸顶效果
 */

public class StickyDecoration extends RecyclerView.ItemDecoration {

    private final TextPaint mTextPaint;
    private final int mTopGap;
    private final int mAlignBottom;
    private Paint mPaint;
    private Resources mResources;
    private Context mContext;

    public StickyDecoration(Context context) {
        mContext = context;

        mResources = mContext.getResources();

        // 设置悬浮栏View的paint
        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setColor(mResources.getColor(R.color.colorAccent));
        
        // 设置悬浮栏TextPaint
        mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
        mTextPaint.setColor(mResources.getColor(R.color.colorPrimaryDark));
        mTextPaint.setTextSize(mResources.getDimensionPixelSize(R.dimen.activity_horizontal_margin));
        mTextPaint.setTextAlign(Paint.Align.LEFT);

        // 悬浮栏的高度
        mTopGap = mResources.getDimensionPixelSize(R.dimen.activity_horizontal_margin);

        // 文本的显示位置
        mAlignBottom = mResources.getDimensionPixelSize(R.dimen.item_decoration_padding);
    }
}
